/**   
 *    
 * @file
 * @brief
 * @文件名	: ImageLoaderWithGifProgressListener
 * @版权所有	: 网龙应用软件开发一部
 * @作  者	: chenqian
 * @创建时间	: 2014-7-21 上午9:34:08 
 * @文件描述	:  
 * @version	Ver 1.1
 */
package com.common.widget.ShowBigImage;

import android.graphics.Bitmap;
import android.view.View;

import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

/**
 * 对GIF图片下载同样进行监听 <br>
 * Created 2014-7-21 上午9:34:08
 * 
 * @version 1.2
 * @author chenqian
 * 
 * @see
 */

public class ImageLoaderWithGifProgressListener extends
		ImageLoaderWithCircleProgressListener {
	protected int mDefaultRid = 0;
	protected IJudgeGif mJudgeGif;
	protected DisplayImageOptions mDisplayOpt;
	protected ImageLoader mImageLoader;

	/**
	 * Creates a new instance of ImageLoaderWithGifProgressListener. <br>
	 * Created 2014-7-21 上午9:37:20
	 * 
	 * @param url
	 *            String
	 * @param imageCircle
	 *            ImageWithLoadingCircle
	 * @param displayOpt
	 *            DisplayImageOptions
	 * @param judgeGif
	 *            IJudgeGif
	 * @param defaultRid
	 *            默认图片id
	 */
	public ImageLoaderWithGifProgressListener(String url,
			ImageWithLoadingCircle imageCircle, DisplayImageOptions displayOpt,
			IJudgeGif judgeGif, int defaultRid) {
		super(url, imageCircle);
		if (null == judgeGif) {
			mJudgeGif = new DefaultJudgeGif();
		} else {
			mJudgeGif = judgeGif;
		}
		mDisplayOpt = displayOpt;
		mImageLoader = ImageLoader.getInstance();
		mDefaultRid = defaultRid;
	}

	@Override
	public void onLoadingComplete(String url, View view, Bitmap loadedImage) {
		super.onLoadingComplete(url, view, loadedImage);
		String absPath = ImageLoader.getInstance().getDiscCacheFileAbsPath(
				mDisplayOpt, url);
		if (mJudgeGif.isGif(absPath, null, true)) {
			// 如果是GIF图片，通过imageloader下载完成后，
			// 需要传递本地保存路径到gif的显示控件
			mImageCircle.showGif(absPath, mDefaultRid);
		} else {
			mImageCircle.showImage(loadedImage);
		}
	}

}
